
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include "Header.h"
#include <stdio.h>

char *cc;



int main(int argc, char* argv[])
{
	//freopen("genome","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t start, end;
	double runTime;
	char *filename = "genome";
	int num = 1000;//modify the length of genome data 
	char *genome;
	int n = 0,i = 0;
	int *inp;
	int *SA;
	genome = (char *) malloc((num+1)*sizeof(char)); 

	read_genome(filename, genome, num);

	start = clock();
	cc = genome;
	n = strlen(cc);

	inp = (int *)malloc( (n+3)*sizeof(int) );
	SA  = (int *)malloc( (n+3)*sizeof(int) );

	for(i=0;i<n;i++)
		inp[i] = to_i(cc[i]);
	inp[i]=0;inp[i+1]=0;inp[i+2]=0;

	for(i=0;i<n+3;i++)
		SA[i] = 0;

	suffixArray(inp,SA,n,MAX_ALPHA);

	//  print all suffixes of genome
	//	for(i = 0 ; i < num ; i++)
	//		print_suffix(cc, SA[i]);

	end = clock();
	runTime = (end - start) / (double) CLOCKS_PER_SEC ;

	printf("CPU linear construct Suffix Array\nNUM: %d \t Time: %f Sec\n", num, runTime);

	int LB = CPU_left_boundary(SA, num, "AT", cc);
	int RB;
	if(LB != -1)
	{
		RB = CPU_right_boundary(SA, num, "ATC", cc);

		//  print all indexed suffixes of genome
		//	for(i = LB ; i <= RB ; i++)
		//		print_suffix(cc, SA[i]);
	}

	int q[48];
	trans_querySeq_to_digits(cc, q); 

	free(genome);
	return 0;
}

